<template>
    <div class="home">
        <Search @search="search"></Search>
        <flowerList ref="flowerList"></flowerList>
    </div>
</template>

<script>
import Search from './search/search.vue'
import flowerList from './flowerList.vue'
export default {
    name: 'Home',
    components: {
        Search,
        flowerList
    },
    methods: {
        //方法接收一个参数 key，是用户输入的搜索关键字
        search(key) {
            if (key) {
                this.$refs.flowerList.search(key)
            } else {
                this.$message.error('输入不能为空！');
            }
        }
    }
}
</script>